import 'package:flutter/material.dart';

class VersionUpdatePage extends StatefulWidget {
  @override
  _VersionUpdatePageState createState() => new _VersionUpdatePageState();
}

class _VersionUpdatePageState extends State<VersionUpdatePage> {

  
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
          centerTitle: true,
          backgroundColor: Colors.white,
          iconTheme: IconThemeData(
            color: Colors.black,
          ),
          title: new Text(
            '版本更新',
            style: new TextStyle(color: Colors.black),
          )),
      body: new Column(
        children: <Widget>[
          Container(
            width: double.infinity,
            height: 280.0,
            child: Padding(
              padding: const EdgeInsets.only(top: 90.0),
              child: Column(
                children: <Widget>[
                  Image.asset(
                    'images/collect_money_cat.png',
                    width: 86.0,
                    height: 86.0,
                  ),
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      '版本升级',
                      style: new TextStyle(
                        color: const Color(0xFF666666),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
          RaisedButton(
            elevation: 0.0,
            onPressed: () => showAlertDialog(context),
            child: Container(
              height: 50.0,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.only(left: 16.0),
                    child: new Text('检查更新'),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(right: 16.0),
                    child: new Text(
                      "V1.0.0",
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  void showAlertDialog(BuildContext context) {
    NavigatorState navigator =
        context.rootAncestorStateOfType(const TypeMatcher<NavigatorState>());
    debugPrint("navigator is null?" + (navigator == null).toString());

    showDialog(
        context: context,
        builder: (_) => new AlertDialog(
                title: new Text("版本升级"),
                content: new Text("本次修复了已知bug"),
                actions: <Widget>[
                  new FlatButton(
                    child: new Text("取消"),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  ),
                  new FlatButton(
                    child: new Text("升级"),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  )
                ]));
  }
}
